package co.baiku.boot.orm.service.impl;

import co.baiku.boot.core.orm.dao.BaseDAO;
import co.baiku.boot.core.orm.service.impl.BaseServiceImpl;
import co.baiku.boot.orm.cache.annotion.CacheInvalid;
import co.baiku.boot.orm.cache.annotion.Caching;
import co.baiku.boot.orm.dao.StudentDAO;
import co.baiku.boot.orm.dto.StudentDto;
import co.baiku.boot.orm.po.Student;
import co.baiku.boot.orm.service.StudentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Transactional(rollbackFor = Exception.class)
@Service
public class StudentServiceImpl extends BaseServiceImpl<Student, StudentDto, Long> implements StudentService {
    @Resource
    private StudentDAO studentDAO;

    @Caching(key = "#id")
    @Override
    public Student getById(Long id) {
        return super.getById(id);
    }

    @CacheInvalid(key = "#id")
    @Override
    public void delete(Long id) {
        super.delete(id);
    }

    @Override
    protected BaseDAO<Student, Long> getBaseDAO() {
        return studentDAO;
    }
}
